package me.hellp.helloworld.design.builder;

import java.util.List;

/** 
 * 指导者，指导使用生成器的接口来构建产品对象 
 * 
 */  
public class Director {  
  
    /** 
     * 持有当前需要使用的生成器对象 
     */  
    private Builder builder;  
  
    /** 
     * 构造方法，传人生成器对象 
     * @param builder 
     */  
    public Director(Builder builder) {  
        this.builder = builder;  
    }  
    
    private String head;
    private List<String> body;
    private String foot;
    
    public Director setHead(String head){
    	this.head = head;
    	return this;
    }
    
    public Director setBody(List<String> body){
    	this.body = body;
    	return this;
    }
    
    public Director setFoot(String foot){
    	this.foot = foot;
    	return this;
    }
    /** 
     * 获取产品对象 
     */  
    public Product build(){
    	builder.buildHeader(this.head);
    	builder.buildBody(this.body);
    	builder.buildFooter(this.foot);
    	
        return builder.getProduct();  
    }  
}  